import os.path
from pprint import pprint
import pandas as pd


class DataOperation:
    def __init__(self, path):
        self.data = pd.read_csv(path)

    # 将读取出来的内容转化为列表列表[[],[]]
    def get_data_tolist(self):
        return self.data.values.tolist()

    # 将读取出来的内容转化为列表字典[{},{}]
    def get_data_to_dict(self):
        return [self.data.iloc[i].to_dict() for i in self.data.index.values]


if __name__ == '__main__':
    print(os.path.abspath(__file__))
    print(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
    path1 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
                         'data/lj_data.csv')
    case = DataOperation(path1)
    pprint(case.get_data_tolist())
    pprint(case.get_data_to_dict())
